﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using OpenAPI.WebBase.Models;
//using OpenAPI.WebBase;


namespace TEST
{
	public class CreateLineOrderRequest
	{

		public RequestData data { get; set; }

		public string opType { get; set; }

		public class RequestData
		{
			/// <summary>
			/// 订单id
			/// </summary>
			public string orderId { get; set; }
			/// <summary>
			/// 供应商产品id
			/// </summary>
			public string resourceId { get; set; }
			/// <summary>
			/// 外部订单id，这里指去哪儿的订单id
			/// </summary>
			public string displayId { get; set; }
			/// <summary>
			/// 游玩日期
			/// </summary>
			public string takeoffDate { get; set; }

			/// <summary>
			/// 总价
			/// </summary>
			public decimal origin { get; set; }
			/// <summary>
			/// 支付金额
			/// </summary>
			public decimal money { get; set; }
			/// <summary>
			/// 联系人
			/// </summary>
			public string contactUser { get; set; }
			/// <summary>
			/// 联系人电话
			/// </summary>
			public string contactMobile { get; set; }
			/// <summary>
			/// 下单时间
			/// </summary>
			public string orderTime { get; set; }
			/// <summary>
			/// 订单状态，对方要求是字符串，2013-11-11 13:43曹广扬修改
			/// </summary>
			public string orderStatus { get; set; }
			
			/// <summary>
			/// 套餐价格ID
			/// </summary>
			public string priceId { get; set; }
			/// <summary>
			/// 套餐价格名称
			/// </summary>
			public string priceTitle { get; set; }
			/// <summary>
			/// 客人收件地址，针对采取快递形式的签证订单有效
			/// </summary>
			public string visaExpressAddress { get; set; }
			/// <summary>
			/// 购买数量
			/// </summary>
			public Count count { get; set; }
			/// <summary>
			/// 产品价格单价
			/// </summary>
			public Price price { get; set; }

			public List<Element> elements { get; set; }
			/// <summary>
			/// 旅客信息
			/// </summary>
			public List<Passenger> passengers { get; set; }

			void Test()
			{
				CreateLineOrderRequest request = new CreateLineOrderRequest()
				{
					data = new RequestData
					{
						contactMobile = "15250482759",
						contactUser = "cgyqu",
						displayId = "123",
						orderId = "hh12345",
						money = 1894.99m,
						orderTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
						orderStatus = "2",
						origin = 2999.99m,
						price = new Price
						{
							adultPrice = 1234,
							childPrice = 123,
							taocanPrice = 123
						},
						count = new Count
						{
							adultCount = 1,
							childCount = 0,
							otherCount = 1,
							roomCount = 1,
							taocanCount = 1
						},
						elements = new List<Element> 
						{
							new Element{date=DateTime.Now.Date,relateId=123,type="123"}
						},
						passengers = new List<Passenger> 
						{
							new Passenger
							{
								idNo="3203122221129992",
								abroadRecord="1",
								idType=1,
								isAdult=true,
								name="cgyqu"
							}
						},
						priceId="1654",
						priceTitle="test",
						resourceId="12345",
						takeoffDate = DateTime.Now.AddDays(10d).ToString("yyyy-MM-dd HH:mm:ss"),
						visaExpressAddress="帝都教化街"
					}
				};
				Console.WriteLine(request.Serializer());
			}
		}

		public class Price
		{
			/// <summary>
			/// 成人价
			/// </summary>
			public decimal adultPrice { get; set; }
			/// <summary>
			/// 儿童价
			/// </summary>
			public decimal childPrice { get; set; }
			/// <summary>
			/// 产品为套餐时，套餐每份价格
			/// </summary>
			public decimal taocanPrice { get; set; }
		}

		public class Count
		{
			/// <summary>
			/// 成人数
			/// </summary>
			public int adultCount { get; set; }
			/// <summary>
			/// 儿童数
			/// </summary>
			public int childCount { get; set; }
			/// <summary>
			/// 产品是套餐的时候套餐份数
			/// </summary>
			public int taocanCount { get; set; }
			/// <summary>
			/// 其他数
			/// </summary>
			public int otherCount { get; set; }
			/// <summary>
			/// 房间数
			/// </summary>
			public int roomCount { get; set; }
		}

		public class Element
		{
			public string type { get; set; }
			/// <summary>
			/// 关联资源id
			/// </summary>
			public int relateId { get; set; }
			/// <summary>
			/// 选择时间
			/// </summary>
			public DateTime? date { get; set; }
		}

		public class Passenger
		{
			/// <summary>
			/// 旅客姓名
			/// </summary>
			public string name { get; set; }
			/// <summary>
			/// 旅客证件类型
			/// </summary>
			public int idType { get; set; }
			/// <summary>
			/// 旅客证件号
			/// </summary>
			public string idNo { get; set; }

			public bool isAdult { get; set; }
			/// <summary>
			/// 出境记录,针对签证产品
			/// 1，一年内有出境该国记录；2，无不良出境记录（如：境外延期境外罚款等），3，一年内有被拒签记录
			/// </summary>
			public string abroadRecord { get; set; }
		}
	}

	//public class CreateLineOrderRequestHost : AllianceApiRequestModelBase, IStructuredPost
	//{


	//	public string PostData
	//	{
	//		get;
	//		set;
	//	}
	//	public StructuredPostDataType DataType
	//	{
	//		get
	//		{
	//			return StructuredPostDataType.Json;
	//		}
	//	}
	//	public CreateLineOrderRequest Request { get; set; }

	//	public void AnalyzeParameters()
	//	{
	//		Request = this.Deserialize<CreateLineOrderRequest>();
	//	}
	//}
}
